From fcea054651a60f39becdf99eff86ca1b211e27df Mon Sep 17 00:00:00 2001 From: robertl Date: Thu, 22 May 2003 14:45:39 +0000 Subject: [PATCH] Fix parsing of blank PCX description fields; Ian Mahuron & myself. Fix indention. --- gpsbabel/pcx.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/gpsbabel/pcx.c b/gpsbabel/pcx.c index 56973a0ff..ac36960d2 100644 --- a/gpsbabel/pcx.c +++ b/gpsbabel/pcx.c @@ -85,23 +85,31 @@ data_read(void) for(;fgets(ibuf, sizeof(ibuf), file_in);) { switch (ibuf[0]) { - case 'W': - sscanf(ibuf, "W %6c %c%lf %c%lf %s %s %ld %40c %*13c %d", + case 'W': + sscanf(ibuf, "W %6c %c%lf %c%lf %s %s %ld", name, &latdir, &lat, &londir, &lon, - date, time, &alt, desc, &symnum); - desc[sizeof(desc)-1] = '\0'; - name[sizeof(name)-1] = '\0'; - wpt_tmp = xcalloc(sizeof(*wpt_tmp), 1); - wpt_tmp->position.altitude.altitude_meters = alt; - wpt_tmp->shortname = xstrdup(name); - wpt_tmp->description = xstrdup(desc); - wpt_tmp->icon_descr = mps_find_desc_from_icon_number(symnum, PCX); - - if (latdir == 'S') lat = -lat; - if (londir == 'W') lon = -lon; - wpt_tmp->position.longitude.degrees = lon/100.0; - wpt_tmp->position.latitude.degrees = lat/100.0; - waypt_add(wpt_tmp); + date, time, &alt); + sscanf(&ibuf[60], "%40c", + desc); + sscanf(&ibuf[116], "%d", + &symnum); + + desc[sizeof(desc)-1] = '\0'; + name[sizeof(name)-1] = '\0'; + wpt_tmp = xcalloc(sizeof(*wpt_tmp), 1); + wpt_tmp->position.altitude.altitude_meters = alt; + wpt_tmp->shortname = xstrdup(name); + wpt_tmp->description = xstrdup(desc); + wpt_tmp->icon_descr = mps_find_desc_from_icon_number(symnum, PCX); + + if (latdir == 'S') lat = -lat; + if (londir == 'W') lon = -lon; + wpt_tmp->position.longitude.degrees = lon/100.0; + wpt_tmp->position.latitude.degrees = lat/100.0; + waypt_add(wpt_tmp); + break; + default: + ; } } } -- 2.30.2